All Packages Class Hierarchy This Package Previous Next Index
Class sun.servlet.http.HttpOutputStream
java.lang.Object
|
+----java.io.OutputStream
|
+----javax.servlet.ServletOutputStream
|
+----sun.servlet.http.HttpOutputStream
- public class HttpOutputStream
- extends ServletOutputStream
This class implements a buffered output stream for writing servlet
response data. It also keeps track of the number of bytes that have
been written, and allows the specification of an optional byte limit
to ensure that the content length has not been exceeded. Additionally,
an observer list is maintained which can be used to notify observers
the first time the stream is written to.
-
buf
- The output buffer.
-
committed
- Indicated whether the buffer has been written to the stream
-
count
- The current number of bytes in the buffer.
-
except
- If set then an I/O exception is pending.
-
length
- The content length for this stream.
-
limit
- The maximum number of bytes that can be written.
-
obs
- The observer that will be notified when the stream is first written.
-
out
- The actual output stream.
-
total
- The total number of bytes written so far.
-
HttpOutputStream()
- Creates a new, uninitialized servlet output stream with a default
buffer size.
-
HttpOutputStream(int)
- Creates a new servlet output stream using the specified buffer size.
-
check(int)
- Checks the output stream for a pending IOException that needs to be
thrown, a content length that has been exceeded, or observers that
need to be notified.
-
close()
- Closes the servlet output stream.
-
finish()
- Finishes the current response.
-
flush()
- Flushes the output stream.
-
flushBytes()
- Flushes the output stream bytes.
-
getContentLength()
- Returns the content length for this output stream, or -1 if not set.
-
getTotal()
- Returns the total number of bytes written so far.
-
init(OutputStream)
- Initializes the output stream with the specified raw output stream.
-
isCommitted()
- Returns whether the output has been committed or not.
-
next()
- Begins the next response.
-
print(HttpDate)
- Prints an HttpDate object.
-
print(String)
- Prints a string.
-
resets()
- Resets the output stream for a new connection.
-
setContentLength(int)
- Sets the content length for this output stream.
-
setHeader(byte[])
-
-
setHeader(byte[], int, int)
-
-
setIOException(IOException)
- Sets the pending IOException for this output stream.
-
setObserver(Observer)
- Sets an observer for this output stream.
-
write(byte[], int, int)
- Writes an array of bytes.
-
write(int)
- Writes a byte.
-
writeOut(byte[], int, int)
-
out
protected OutputStream out
- The actual output stream.
buf
protected byte buf[]
- The output buffer.
count
protected int count
- The current number of bytes in the buffer.
total
protected int total
- The total number of bytes written so far.
limit
protected int limit
- The maximum number of bytes that can be written. This is initially
set to -1 in order to indicate that observers must be notified.
length
protected int length
- The content length for this stream.
obs
protected Observer obs
- The observer that will be notified when the stream is first written.
except
protected IOException except
- If set then an I/O exception is pending.
committed
protected boolean committed
- Indicated whether the buffer has been written to the stream
HttpOutputStream
public HttpOutputStream(int size)
- Creates a new servlet output stream using the specified buffer size.
- Parameters:
- size - the output buffer size
HttpOutputStream
public HttpOutputStream()
- Creates a new, uninitialized servlet output stream with a default
buffer size.
init
public void init(OutputStream out) throws IOException
- Initializes the output stream with the specified raw output stream.
- Parameters:
- out - the raw output stream
next
public void next()
- Begins the next response.
finish
public void finish() throws IOException
- Finishes the current response.
resets
public void resets()
- Resets the output stream for a new connection.
getTotal
public int getTotal()
- Returns the total number of bytes written so far.
setContentLength
public void setContentLength(int len)
- Sets the content length for this output stream.
- Parameters:
- len - the content length
getContentLength
public int getContentLength()
- Returns the content length for this output stream, or -1 if not set.
setObserver
public void setObserver(Observer obs)
- Sets an observer for this output stream. The observer will be
notified when the stream is first written to.
setIOException
public void setIOException(IOException e)
- Sets the pending IOException for this output stream.
- Parameters:
- e - the IOException
isCommitted
public boolean isCommitted()
- Returns whether the output has been committed or not.
check
protected void check(int len) throws IOException
- Checks the output stream for a pending IOException that needs to be
thrown, a content length that has been exceeded, or observers that
need to be notified.
- Parameters:
- len - the number of bytes about to be written
write
public void write(int b) throws IOException
- Writes a byte. This method will block until the byte is actually
written.
- Parameters:
- b - the byte
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- write in class OutputStream
write
public void write(byte b[],
int off,
int len) throws IOException
- Writes an array of bytes. This method will block until all the bytes
are actually written.
- Parameters:
- b - the data to be written
- off - the start offset of the data
- len - the number of bytes to write
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- write in class OutputStream
flush
public void flush() throws IOException
- Flushes the output stream.
- Overrides:
- flush in class OutputStream
flushBytes
protected void flushBytes() throws IOException
- Flushes the output stream bytes.
print
public void print(String s) throws IOException
- Prints a string.
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- print in class ServletOutputStream
print
public void print(HttpDate d) throws IOException
- Prints an HttpDate object.
close
public void close() throws IOException
- Closes the servlet output stream.
- Overrides:
- close in class OutputStream
setHeader
public void setHeader(byte buf[]) throws IOException
setHeader
public void setHeader(byte buf[],
int offset,
int len) throws IOException
writeOut
protected void writeOut(byte buf[],
int offset,
int len) throws IOException
All Packages Class Hierarchy This Package Previous Next Index